<div class="modal fade bs-modal-md" id="modelContent">
	<div class="modal-dialog modal-md">
        <div class="modal-content"></div>
    </div>
</div> 
<div class="portlet box green">
	<div class="portlet-title">
	    <div class="caption"><i class="fa fa-cog"></i>查询内容 </div>
		<div class="tools">
			<a href="javascript:;" class="collapse right" data-original-title="" title=""> </a>
			<!-- <a href="" class="fullscreen" data-original-title="" title=""> </a> -->
    	</div>
    	<div class="actions">
			<a href="javascript:;" class="btn white btn-sm ajax-search"><i class="fa fa-search"></i> 查询 </a>
			<a href="javascript:;" class="btn white btn-sm search-reset"><i class="fa fa-eraser"></i> 清除 </a>
		</div>
	</div>
	<div class="portlet-body form">
	   	<form action="/userInfo/list" class="form-horizontal" method="get" id="searchForm" onsubmit="return false">
			<div class="form-body">
				<div class="row">
					<div class="form-group">
						<div class="col-md-3">
							<label class="col-md-4 control-label">会员号：</label>
							<div class="col-md-8">
						    	<input type="number" class="form-control" name="id" value="$!id">
							</div>
						</div>
						<div class="col-md-3">
							<label class="col-md-4 control-label">手机号：</label>
							<div class="col-md-8">
						    	<input type="text" class="form-control" name="phone" value="$!phone">
							</div>
						</div>
						<!-- <div class="col-md-3">
							<label class="col-md-4 control-label">邮箱：</label>
							<div class="col-md-8">
						    	<input type="text" class="form-control" name="email" value="$!email">
							</div>
						</div> -->
						<div class="col-md-3">
							<label class="col-md-4 control-label">会员等级：</label>
							<div class="col-md-8">
						    	<select class="form-control bs-select"  name="userLevel">
						    		<option value="">请选择</option>
					    		#foreach($memberLevel in $!memberLevelList)
					    			<option value="$!memberLevel.level">$!memberLevel.name</option>
					    		#end
						    	</select>
							</div>
						</div>
					</div>
					<div class="form-group">
						<div class="col-md-3">
							<label class="control-label col-md-4">创建时间</label> 
							<label class="col-md-8">
								<input class="form-control" type="text" name="startTime" id="startTime" value="$!startTime" readonly>
								<i class="fa fa-calendar" style="position: absolute;right: 10px;top: 10px"></i>
							</label>
						</div>
						<div class="col-md-3">
							<label class="control-label col-md-4">至：</label> 
							<label class="col-md-8">
								<input class="form-control" type="text" name="endTime" id="endTime" value="$!endTime" readonly>
								<i class="fa fa-calendar" style="position: absolute;right: 10px;top: 10px"></i>
							</label>
						</div>
					</div>
	    		</div>
			</div>
		</form>
	</div>
</div>
<div class="portlet box green">
    <div class="portlet-title">
		<div class="caption"><i class="fa fa-cogs"></i>数据列表
		</div>
		<div class="tools">
			<a href="javascript:;" class="collapse" data-original-title="" title=""> </a>
		</div>
		<div class="actions left">
			<a href="javascript:;"  class="btn white btn-sm delete-tab" ><i class="fa fa-trash"></i>删除</a>
			<a href="#modelContent" class="btn white btn-sm  edit-model"  data-toggle="modal"  thref="/userInfo/expEdit"><i class="fa fa-edit" ></i>修改经验值</a>
			<a href="#modelContent" class="btn white btn-sm  edit-model"  data-toggle="modal"  thref="/userInfo/scoreEdit"><i class="fa fa-edit" ></i>修改积分</a>
			
			<a href="javascript:;"  class="btn white btn-sm reinstall-tab" ><i class="fa fa-eraser"></i>重置密码</a>
			<a href="javascript:;"  class="btn white btn-sm user-defined" ><i class="fa fa-check-square"></i>自定义列表</a>
			<a href="#modelContent" class="btn white btn-sm ajax-model-get" data-toggle="modal" code="Membership.user.member.add" thref="/userInfo/add" ><i class="fa fa-plus"></i> 新增 </a>
		</div>
	 	<div id="qrMl" style="display: none;top: 50%; right: 50%; z-index: 100; position: absolute; background-color: #fff; width: 200px;height: 100px;box-shadow: 5px 5px rgba(102,102,102,.1);border: 1px solid #eee;">
			<button type="button" class="close close-click" style="margin: 10px;"></button>
            <select  class="form-control bs-select listname" data-size="8" multiple>
			</select>
		</div>
    </div>
    <div class="portlet-body">
    	       <div class="form-group">
					<div class="alert alert-warning">
						<strong> 注：</strong>
						1.系统所有会员，只要与系统有过接触的会员都将存在于系统，不管是否关注。只接触未关注的会员，视为临时会员。正式会员为已关注过会员。
     					<p> 2.会员推荐人在会员成为正式会员确定，或者临时会员在系统下单确定，推荐人一旦确定将不可改变。新增的密码与重置的密码默认为#if($!defaultpwd) $!defaultpwd #else 123456 #end<p>
					</div>
				</div>
    	<div class="tabbable-line ">
	    	<div class="dataTables_wrapper no-footer">
				<div class="table-scrollable">
					 <table class="table table-striped table-bordered table-hover icheck-table" id="tableCategory">
						  <thead>
							<tr>
								<th style="width: 20px">
									<input type="checkbox" class="icheck group-icheck"/>
								</th>
								<th>会员号</th>
								<th>昵称/姓名</th>
								<th>会员等级</th>
								<th>手机号</th>
								<th>消费额</th>
								<th>积分</th>
								<th>公众平台</th>
								<th>会员来源</th>
								<th>推荐人数</th>
								<th>推荐人id</th>
								<th>注册时间</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							#foreach($userInfo in $!userInfoPage.result)
								#set($memberLevel = $!memberLevelMap.get($!userInfo))
								#set($nubmer = $!ContMap.get($userInfo))
								
							<tr>
								<td>
									<input type="checkbox" name="checkboxes" class="icheck" value="$!userInfo.id" />
								</td>
								<td><a href="userInfo/detail?id=$!userInfo.id" class="ajaxify" >$!userInfo.id</a></td>
								<td>
									#if($!userInfo.idCardAuthState == "AUTH_PASS")
										$!userInfo.realname
									#else
										 $!userInfo.nickname
									 #end
								</td>
								<td>$!memberLevel.name</td>
								<td>$!userInfo.phone</td>
								<td>$!userInfo.expenditure</td>
								<td>$!userInfo.score</td>
								<td></td>
								<td>$!userInfo.MemberSource</td>
								<td>$nubmer</td>
								<td>$!userInfo.commendFriendId</td>
								<td>$!userInfo.createTime</td>
								<td>
									<a href="#modelContent" class="btn green btn-outline btn-sm ajax-model-get" code="Membership.user.member.edit" data-toggle="modal"  thref="/userInfo/edit?id=$!userInfo.id"><i class="fa fa-edit" ></i>编辑</a>
								</td>
							</tr>								
							#end
						</tbody>
					</table>
				</div>
				#set($page= $!userInfoPage)
				#set($pageUrl="/userInfo/list?$!queryString&pageNo=")
				#parse("_page.htm")
			</div>
		</div>
    </div>
</div>
<script src="/assets/scripts/views-date.js" type="text/javascript"></script>
<script type="text/javascript" src="/assets/scripts/views-permission.js"></script>
<script type="text/javascript" src="/assets/scripts/views-icheck.js"></script>
<script type="text/javascript">
	var userName="$!loginUser.username";

     $("input[name=id]").focus();
     
	 var pageContentBody = $('.page-content .page-content-body');
     
     function getcbvalue(){
 		var array = new Array()
 		var target= $("input[name='checkboxes']");
 		//循环加入数组
 		
 			$.each(target,function(i,v){
 				if(v.checked){
 					array.push($(v).val());
 				}
 			});
		 	return array; 
	  }
     
     $(".delete-tab").click(function(){
   	  	var uIArray= getcbvalue();
		bootbox.setLocale("zh_CN");

		bootbox.confirm("确定删除这些用户吗？", function(state) {
				if (state && uIArray.length > 0) {
					$.post("/userInfo/delete", {
						"uIArray" : uIArray
					}, function(result) {
						if (result.code == 0) {
							toastr.success(result.msg);
							pageContentBody.load("/userInfo/list");
						} else {
							toastr.warning(result.msg);
						}
					}, "json");
				}else{
					toastr.warning("请勾选会员！");
				}
			})

	})
	/**
		重 置密码
	*/
	
	$(".reinstall-tab").click(function(){
		var uIArray= getcbvalue();
		bootbox.setLocale("zh_CN");
		if(uIArray.length == 0){
			toastr.warning("请勾选会员！");
			return ;
		}
		bootbox.confirm("确定重置这些会员的密码吗？", function(state) { 
			if (state) {
				$.post("/userInfo/reinstall", {
					"uIArray" : uIArray
				}, function(result) {
					if (result.code == 0) {
						toastr.success(result.msg);
						pageContentBody.load("/userInfo/list");
					} else {
						toastr.warning(result.msg);
					}
				}, "json");
			}
		});
	})
	
	     /**
      *
      * 获得 鼠标点击坐标
      */
     function getMousePos(event) {
            var e = event || window.event;
            var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
            var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
            var x = e.pageX || e.clientX + scrollX;
            var y = e.pageY || e.clientY + scrollY;
            return { 'x': x, 'y': y };
      }
     
	function origin(target){
		 var m = getMousePos(event);
   	  	 target.css("top",(m.y-30)+"px");
    	 target.css("left",(m.x-100)+"px");
	}
	$(".user-defined").click(function(){
		var target= $("#qrMl");
		 target.toggle();
		 origin(target);
 
	});

	/**
	 *  窗口关闭
	 *  
	 */
	$(".close-click").click(function() {
		$("#qrMl").hide();
	})
	
	
	customList.init({pageName:"userInfoList"+userName,tabelId:"#tableCategory"});
	// 	$(".user-defined").
	
	     
     $(".edit-model").click(function(e){
    	 var pageContentBody = $($(this).attr("href")).find(".modal-content");
     	var pIdArray= getcbvalue();
    	if(pIdArray.length>0){
    	    e.preventDefault();
	        var url = $(this).attr("thref");
	        App.startPageLoading();
	        $.ajax({
	            type: "GET",
	            cache: false,
	            url: url,
	            dataType: "html",
	            data:{"idArry":pIdArray},
	            success: function (res) {
	                App.stopPageLoading();
	                pageContentBody.html(res);
	                Layout.fixContentHeight(); // 修复内容高度
	            },
	            error: function (xhr, ajaxOptions, thrownError) {
	                pageContentBody.html('<h4>服务器异常!</h4>');
	                App.stopPageLoading();
	            }
	        });
    	}else{
    		pageContentBody.html('<h4>请选择会员！</h4>');
    	}
     })
	
</script>
<script src="/assets/plugins/bootstrap-select/js/components-bootstrap-select.js" type="text/javascript"></script>